﻿(function(){CodeMirror.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(d,c){return/^[;{}]$/.test(c)}});CodeMirror.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(d,c,b,a){return this.jsonMode?/^[\[,{]$/.test(c)||/^}/.test(b):";"==c&&a.lexical&&")"==a.lexical.type?!1:/^[;{}]$/.test(c)&&!/^;/.test(b)}});CodeMirror.extendMode("xml",{commentStart:"<\!--",commentEnd:"--\>",newlineAfterToken:function(d,c,b){return"tag"==d&&/>$/.test(c)||
/^</.test(b)}});CodeMirror.defineExtension("commentRange",function(d,c,b){var a=this,e=CodeMirror.innerMode(a.getMode(),a.getTokenAt(c).state).mode;a.operation(function(){if(d)a.replaceRange(e.commentEnd,b),a.replaceRange(e.commentStart,c),c.line==b.line&&c.ch==b.ch&&a.setCursor(c.line,c.ch+e.commentStart.length);else{var g=a.getRange(c,b),i=g.indexOf(e.commentStart),f=g.lastIndexOf(e.commentEnd);-1<i&&(-1<f&&f>i)&&(g=g.substr(0,i)+g.substring(i+e.commentStart.length,f)+g.substr(f+e.commentEnd.length));
a.replaceRange(g,c,b)}})});CodeMirror.defineExtension("autoIndentRange",function(d,c){var b=this;this.operation(function(){for(var a=d.line;a<=c.line;a++)b.indentLine(a,"smart")})});CodeMirror.defineExtension("autoFormatRange",function(d,c){for(var b=this,a=b.getMode(),e=b.getRange(d,c).split("\n"),g=CodeMirror.copyState(a,b.getTokenAt(d).state),i=b.getOption("tabSize"),f="",l=0,j=0==d.ch,k=0;k<e.length;++k){for(var h=new CodeMirror.StringStream(e[k],i);!h.eol();){var m=CodeMirror.innerMode(a,g),
o=a.token(h,g),n=h.current();h.start=h.pos;if(!j||/\S/.test(n))f+=n,j=!1;if(!j&&m.mode.newlineAfterToken&&m.mode.newlineAfterToken(o,n,h.string.slice(h.pos)||e[k+1]||"",m.state))f+="\n",j=!0,++l}!h.pos&&a.blankLine&&a.blankLine(g);j||(f+="\n",j=!0,++l)}b.operation(function(){b.replaceRange(f,d,c);for(var a=d.line+1,e=d.line+l;a<=e;++a)b.indentLine(a,"smart");b.setSelection(d,b.getCursor(!1))})})})();